﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:params="http://schemas.codeplex.com/elysium/params"
                    xmlns:metro="http://schemas.codeplex.com/elysium"
                    xmlns:controls="clr-namespace:Framework.UI.Controls">
    <ResourceDictionary.MergedDictionaries>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Converter.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Brush.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/Elysium/CommandButton.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/Elysium/ToggleCommandButton.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/Elysium/DropDownCommandButton.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/ElysiumExtra/BorderFix.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="{x:Type metro:ApplicationBar}" TargetType="{x:Type metro:ApplicationBar}" >
        <Style.Resources>
            <ResourceDictionary>
                <Style TargetType="{x:Type metro:CommandButton}" BasedOn="{StaticResource CommandButtonApplicationBarStyle}" />
                <Style TargetType="{x:Type metro:ToggleCommandButton}" BasedOn="{StaticResource ToggleCommandButtonApplicationBarStyle}" />
                <Style TargetType="{x:Type metro:DropDownCommandButton}" BasedOn="{StaticResource DropDownCommandButtonApplicationBarStyle}" />
                <Storyboard x:Key="OpenedStoryboard">
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                   BeginTime="0" 
                                                   Duration="0">
                        <DiscreteObjectKeyFrame KeyTime="0">
                            <ObjectKeyFrame.Value>
                                <Visibility>Collapsed</Visibility>
                            </ObjectKeyFrame.Value>
                        </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </ResourceDictionary>
        </Style.Resources>
        <Setter Property="Background" Value="{StaticResource AccentBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.ContentFontSize),Mode=OneWay}" />
        <Setter Property="FontStretch" Value="Medium" />
        <Setter Property="FontStyle" Value="Normal" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.BoldPadding),Mode=OneWay}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type metro:ApplicationBar}">
                    <controls:BorderFix Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}"
                            TextBlock.Foreground="{TemplateBinding Foreground}" 
                            TextBlock.FontFamily="{TemplateBinding Control.FontFamily}" 
                            TextBlock.FontSize="{TemplateBinding FontSize}" 
                            TextBlock.FontStretch="{TemplateBinding FontStretch}" 
                            TextBlock.FontStyle="{TemplateBinding FontStyle}" 
                            TextBlock.FontWeight="{TemplateBinding FontWeight}" 
                            TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" 
                            TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" 
                            RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" 
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <ItemsPresenter/>
                    </controls:BorderFix>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger DataTrigger.Binding="{Binding RelativeSource={RelativeSource Self},Path=FontSize,Mode=OneWay,Converter={StaticResource IsGreaterThanConverter},ConverterParameter=18}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
            </DataTrigger>
            <EventTrigger RoutedEvent="Closed">
                <BeginStoryboard x:Name="BeginOpenedStoryboard" Storyboard="{StaticResource OpenedStoryboard}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Opening">
                <StopStoryboard BeginStoryboardName="BeginOpenedStoryboard" />
            </EventTrigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>